import 'package:flutter/widgets.dart';

typedef RootWidgetBuilder = Widget Function(NavigatorObserver);

class APMProvider {
  APMProvider._();
  static final APMProvider _instance = APMProvider._();

  VolcengineProvider? _provider;

  static set instance(VolcengineProvider volcengine) {
    _instance._provider = volcengine;
  }

  static VolcengineProvider get instance => _instance._provider!;
}

abstract class VolcengineProvider {
  void enableTraceApp(bool toggle);

  void runVolcengineTraceApp(
    RootWidgetBuilder builder, {
    bool monitorNetWork = false,
    bool enableLog = false,
  });

  Future<void> reportEvent(
    String eventName, {
    Map<String, dynamic>? category,
    Map<String, dynamic>? metric,
    Map<String, dynamic>? extra,
  });

  void info({required String tag, required String message});
  void warn({required String tag, required String message});
  void error({required String tag, required String message});
  void debug({required String tag, required String message});

  void selectTab(String name);

  APMDebug get apmDebug;
}

abstract class APMDebug {
  void makeAppCrash();
  void makeAppFrozen();
  void makeUserException();
  void makeCPUException();
  void makeAppOutOfMemeory();
}
